<!--
 * @Descripttion: 
 * @version: 
 * @Author: mmzhang
 * @Date: 2021-07-21 15:12:27
 * @LastEditTime: 2022-11-14 11:13:43
-->
<template>
  <div>
    <div v-for="(item,index) in noticesMsg" :key="index" class="slot-info">
      <!--图文-->
      <!--退签  退购-->
      <div v-if="item.orderType=='CONTRACT_BACKING' || item.orderType=='ORDER_BACKING'">
        <div class="flex flex-horizontal-between">
          <div class="flex">
            <Icon type="md-warning" :size="20" color="#13227a"
              style="line-height:50px;margin-right:10px;" />
            <p class="desc-text">{{item.message}}</p>
          </div>
          <p>{{item.orderType=='CONTRACT_BACKING'?'退签':'退购'}}单编号：{{item.backCode}}<span
              @click="linkOrderParams(item)" class="view hand">查看详情</span></p>
        </div>
        <ul class="flex flex-wrap">
          <li v-for="(itemMsg,indexMsg) in msgList" :key="indexMsg"
            :style="{'width':itemMsg.inline?'100%':'50%'}">
            <template v-if="itemMsg.key=='residueBill' || itemMsg.key=='accumulateMoney'">
              <div v-if="item.orderType=='CONTRACT_BACKING'" class="flex">
                <p class="text-right name">{{itemMsg.name}}：</p>
                <p>{{$tool.formatterMoney(item[itemMsg.key])}}元</p>
              </div>
            </template>
            <template v-else-if="itemMsg.key=='orAnnexList'">
              <div class="flex">
                <p class="text-right name">{{itemMsg.name}}：</p>
                <enclosure-img :images="item.orAnnexList" :showDownLoad="false"
                  :showDelete="false"> </enclosure-img>
              </div>
            </template>
            <template v-else>
              <div class="flex">
                <p class="text-right name"><span
                    v-show="itemMsg.statusName">{{item.orderType=='CONTRACT_BACKING'?'退签':'退购'}}</span>{{itemMsg.name}}：
                </p>
                <p>{{item[itemMsg.key]}}</p>
              </div>
            </template>
          </li>
        </ul>
      </div>
      <!--破底价-->
      <div v-else-if="item.orderType=='SUB_BREAK_LOW_PRICE'">
        <div class="flex">
          <Icon type="md-warning" :size="20" color="#13227a"
            style="line-height:26px;margin-right:10px;" />
          <p class="desc-title">审核建议</p>
        </div>
        <p class="desc-reason">
          {{item.backReason}}</p>
        <div class="flex flex-horizontal-between">
          <p class="desc-reason">
            {{item.createDate}}</p>
          <p class="desc-reason">审核人：
            {{item.auditName}}</p>
        </div>
      </div>
      <!--引用驳回内容-->
      <div class="desc-detail" v-else-if="item.backReason!='-'">
        <div>
          <div class="flex">
            <Icon type="md-warning" :size="20" color="#13227a"
              style="line-height:26px;margin-right:10px;" />
            <p class="desc-title">{{item.message}}</p>
          </div>
          <p class="desc-reason">
            {{item.backReason}}</p>
        </div>
      </div>
      <!--文字 + 链接-->
      <div v-else-if="item.skipId!='-'">
        <div class="flex">
          <Icon type="md-warning" :size="20" color="#13227a"
            style="line-height:50px;margin-right:10px;" />
          <p class="desc-text">{{item.message}}<span @click="linkOrderParams(item)"
              class="view hand">查看详情</span></p>
          <p @click="alreadyKnowFun(item)" v-if="item.showKnow" class="view hand">我知道了</p>
        </div>
      </div>
      <!--展示文字内容-->
      <div class="flex" v-else-if="item.skipId=='-'">
        <Icon type="md-warning" :size="20" color="#13227a"
          style="line-height:50px;margin-right:10px;" />
        <p class="desc-text">{{item.message}}</p>
      </div>
    </div>
  </div>
</template>
<script>
  import enclosureImg from '@/components/enclosureImg.vue'
  import adjustMgr from '@/biz/sales/adjustOrder'
  export default {
    components: { enclosureImg },
    props: ['detailMsg', 'orderStatusName', 'buildingId', 'subscriptionId'],
    data() {
      return {
        isView: this.$route.meta.isbuild == 'nobuildpage' ? true : false, // 是否是汇总数据跳转
        msgList: [
        {
          name: '日期',
          key: 'backDate',
          statusName: true,
          inline: true,
        },
        {
          name: '累计已到账房款',
          key: 'accumulateMoney',
          statusName: false,
          inline: false,
        },
        {
          name: '剩余未到账房款',
          key: 'residueBill',
          statusName: false,
          inline: false,
        },
        {
          name: '原因',
          key: 'backReason',
          statusName: true,
          inline: true,
        },
        {
          name: '附件',
          key: 'orAnnexList',
          statusName: false,
          inline: true,
        }],
        noticesMsg: []
      }
    },
    created() {
      this.noticesMsg = this.orderStatusName == '认购' ? this.detailMsg.orderNoticeVoList : this
        .detailMsg.notices

      this.noticesMsg.forEach(ele => {
        if (ele.orAnnexList && ele.orAnnexList != '-') {
          ele.orAnnexList = JSON.parse(ele.orAnnexList)
        } else {
          ele.orAnnexList = []
        }
      });
    },
    mounted() {},
    methods: {
      alreadyKnowFun(item) {
        let params = {
          adjustmentId: item.skipId,
          orderId: this.$route.query.businessId
        }
        adjustMgr.updateAdjustmentPromptStatusFun(params).then(res => {
          this.$emit('onGetOrderDetail')
        }).catch(err => {})
      },
      linkOrderParams(item) {
        // 认购: 'SUBSCRIPTION',
        // 退购: 'SUBSCRIPTION_BACK',
        // 签约: 'CONTRACT',
        // 退签: 'CONTRACT_BACK',
        // 认购调整: 'SUBSCRIPTION_ADJUSTMENT',
        // 签约调整: 'CONTRACT_ADJUSTMENT',

        // 认购: 'RG',
        // 退购: 'UR',
        // 签约: 'QY',
        // 退签: 'UQ',
        // 认购调整: 'TR',
        // 签约调整: 'TQ',
        let orderParams = {}
        let type = item.orderCode.slice(0, 2)

        switch (type) {
          case 'RG':
            orderParams = {
              orderNum: item.orderCode, // 单号
              businessId: item.skipId, // 业务id
              buildingId: this.buildingId,
              subscriptionId: ''
            }
            break
          case 'UR':
            orderParams = {
              orderNum: item.orderCode, // 单号
              businessId: item.skipId, // 业务id
              buildingId: this.buildingId,
              subscriptionId: ''
            }
            break
          case 'QY':
            orderParams = {
              orderNum: item.orderCode, // 单号
              businessId: item.skipId, // 业务id
              buildingId: this.buildingId,
              subscriptionId: this.subscriptionId,
            }
            break
          case 'UQ':
            orderParams = {
              orderNum: item.orderCode, // 单号
              businessId: item.skipId, // 业务id
              buildingId: this.buildingId,
              subscriptionId: '',
            }
            break
          case 'TR':
            orderParams = {
              orderNum: item.orderCode, // 单号
              businessId: item.skipId, //业务id
              orderType: '认购'
            }
            break
          case 'TQ':
            orderParams = {
              orderNum: item.orderCode, // 单号
              businessId: item.skipId, //业务id
              orderType: '签约'
            }
            break
          default:
            break
        }
        this.linkOrderFun(orderParams)
      },
    },
  }
</script>
<style lang="scss" scoped>
  .slot-info {
    margin-bottom: 10px;
    padding: 0 20px;
    background-color: #fefcec;

    p {
      line-height: 50px;
    }

    .desc-title {
      line-height: 30px;
    }

    .view {
      margin-left: 20px;
      color: #2d8cf0;
    }

    ul {
      li {
        width: 50%;
        line-height: 50px;

        .name {
          width: 150px;
        }
      }
    }
  }
</style>